﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace Microsoft.Samples.DslTools.ConfigurationSectionDesigner
{
    [Serializable]
    public class AttrSpec
    {
        public string Namespace { get; set; }
        public string AttributeClass { get; set; }

        public AttrSpec()
        {
            Namespace = "";
            AttributeClass = "";
        }

        public override string ToString()
        {
            if( !string.IsNullOrEmpty( AttributeClass ) )
                if( !string.IsNullOrEmpty( Namespace ) )
                    return string.Format( "global::{0}.{1}", Namespace, AttributeClass );
            return "";
        }
    }

    public class AttrSpecList : List<AttrSpec>
    {
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append( "[" );
            foreach( AttrSpec att in this )
                sb.AppendFormat( "{0}, ", att.ToString() );
            if( this.Count > 0 )
                sb.Remove( sb.Length - 2, 2 );
            sb.Append( "]" );

            return sb.ToString();
        }
    }
}
